package com.itheima.Controller;

import com.itheima.Service.SetmealService;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/setmeal")
@Api(tags = "体检套餐")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;


    @PostMapping("/getSetmeal")
    @ApiOperation("获取所有套餐信息")
    public Result getSetmeal(){
        List<Setmeal> list = setmealService.getSetmeal();
        return new Result(true,"查询套餐数据成功",list);
    }

    @PostMapping("/findById")
    @ApiOperation("根据套餐id查询套餐详情，包含（套餐基本信息、套餐关联的检查组、检查组关联的检查项）")
    public Result findById(@RequestParam String id){
        log.info("根据id查询套餐详情:{}",id);
        Setmeal setmeal = setmealService.findById(Integer.parseInt(id));
        return new Result(true,"查询套餐数据成功",setmeal);
    }

}
